home *** CD-ROM | disk | FTP | other *** search
-
-
- Listing 4
-
- #define MAXDATEPRINTS 10
-
- date_print2(date)
- date date; /* internal date form */
- {
- static struct datecache {
- date internal;
- printable_date external;
- } dates[MAXDATEPRINTS];
-
- static struct datecache *d_last_used = dates;
- #define next_date(x) ((x==&dates[MAXDATEPRINTS-1])?dates:x+1)
-
- /* last one used is highly likely */
- struct datecache *d = d_last_used;
-
- do {
- if (d->internal == date) {
- d_last_used = d;
- return(d->external);
- }
- d = next_date(d);
- } while (d != d_last_used);
-
- /* we have moved all the way around the buffer */
- /* and didn't find it in cache */
- /* get next buffer */
- d_last_used = next_date(d);
-
- /* actually do the work and convert date */
- /* into a printable representation */
- .....
- memcpy(d_last_used->external,....);
- return(d_last_used->external);
- }
-
-
-